package com.cskaoyan.controller;


import com.cskaoyan.bean.baseresultVO.BaseData;
import com.cskaoyan.bean.baseresultVO.BaseParam;
import com.cskaoyan.bean.baseresultVO.BaseRespVo;
import com.cskaoyan.bean.brand.brandBo.BrandBo;
import com.cskaoyan.bean.brand.brandBo.BrandBoEx;
import com.cskaoyan.bean.domain.Brand;
import com.cskaoyan.service.BrandService;
import org.springframework.web.bind.annotation.*;


import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Date;

/**
 * <p>
 * 品牌商表 前端控制器
 * </p>
 *
 * @author looper
 * @since 2021-11-29
 */
@RestController
@RequestMapping("admin/brand")
public class BrandController {

    @Resource
    BrandService service;

    @GetMapping("list")
    public BaseRespVo<BaseData> getBrandList(BaseParam baseParam,Integer id,String name) {
      BaseData brandList = service.getBrandsByBaseParam(baseParam,id,name);
      return BaseRespVo.ok(brandList);
    }

    @PostMapping("delete")
    public BaseRespVo getDeleteById(@RequestBody Brand brand){
        Integer id = brand.getId();
        Date time = new Date();
        //逻辑删除
       Integer code = service.getDeletById(id,time);
       return   BaseRespVo.ok(null);

    }
    @PostMapping("update")
    public  BaseRespVo getUpdate(@RequestBody @Valid Brand brand){
        Date date = new Date();
        Brand bo = service.getUpdate(brand,date);
        return   BaseRespVo.ok(bo);
    }
    @PostMapping("create")
    public BaseRespVo getCreate(@RequestBody Brand brand){
        Date date = new Date();
        brand.setAddTime(date);
        Brand insertBrand = service.getInsert(brand);
       return BaseRespVo.ok(insertBrand);
    }



}

